package com.future.lock.me.order.entity.bean;

import java.util.List;

import static com.future.lock.me.order.entity.bean.OrderListInfoBean.ORDER_STATUS_CANCELED;
import static com.future.lock.me.order.entity.bean.OrderListInfoBean.ORDER_STATUS_FINISHED;
import static com.future.lock.me.order.entity.bean.OrderListInfoBean.ORDER_STATUS_PAIED;
import static com.future.lock.me.order.entity.bean.OrderListInfoBean.ORDER_STATUS_REFUNDED;
import static com.future.lock.me.order.entity.bean.OrderListInfoBean.ORDER_STATUS_WAIT_FOR_DELIVERY;
import static com.future.lock.me.order.entity.bean.OrderListInfoBean.ORDER_STATUS_WAIT_TO_PAY;
import static com.future.lock.me.order.entity.bean.OrderListInfoBean.ORDER_STATUS_WAIT_TO_REFUND;

/**
 * Created by yzh on 2017/12/17.
 */

public class OrderDetailsBean {
    public static final int TYPE_NORMAL = 0;
    public static final int TYPE_TRAIL = 0;


    /**
     * order_id : 1
     * order_sn : TEST100202020
     * trade_no : 312321321312
     * goods_id : 1
     * goods_num : 2
     * user_id : 1
     * type : 0
     * is_install : 0
     * province : 浙江省
     * city : 杭州市
     * county : 西湖区
     * address : 123
     * consignee : 123
     * phone : 13111111111
     * goods_price : 100.00
     * install_fee : 0.00
     * added_fee : 0.00
     * discount_amount : 0.00
     * order_amount : 100.00
     * pay_type : 0
     * wuliu_type:"0",
     * express_code : TYO
     * express_name : 物流数据
     * express_no : 812431841403
     * status : 0
     * remark : null
     * pay_time : 2017-11-23 21:18:52
     * create_time : 2017-11-23 21:18:52
     * update_time : 2017-11-23 21:18:52
     * goods_name : 测试商品
     * "province_name": "浙江省",
     * "city_name": "杭州市",
     * "county_name": "江干区"
     * head_img : http://www.baidu.com
     * express_info : {"LogisticCode":"812431841403","ShipperCode":"YTO","Traces":[{"AcceptStation":"【浙江省杭州市滨江区滨和公司】 已收入","AcceptTime":"2017-12-02 08:40:47"},{"AcceptStation":"客户 签收人: 丰巢柜 已签收 感谢使用圆通速递，期待再次为您服务","AcceptTime":"2017-12-02 11:26:11"}],"Reason":"物流数据"}
     */

    private String order_id;
    private String order_sn;
    private String trade_no;
    private String goods_id;
    private int goods_num;
    private String user_id;
    private int type;
    private boolean is_install;
    private String province;
    private String city;
    private String county;
    private String address;
    private String consignee;
    private String phone;
    private float goods_price;
    private float install_fee;
    private float added_fee;
    private float discount_amount;
    private float order_amount;
    private int pay_type;
    private int wuliu_type;
    private String express_code;
    private String express_name;
    private String express_no;
    private int status;
    private Object remark;
    private String pay_time;
    private String create_time;
    private String update_time;
    private String goods_name;
    private String head_img;
    private String province_name;
    private String city_name;
    private String county_name;
    private ExpressInfoBean express_info;

    public String getOrder_id() { return order_id;}

    public void setOrder_id(String order_id) { this.order_id = order_id;}

    public String getOrder_sn() { return order_sn;}

    public void setOrder_sn(String order_sn) { this.order_sn = order_sn;}

    public String getTrade_no() { return trade_no;}

    public void setTrade_no(String trade_no) { this.trade_no = trade_no;}

    public String getGoods_id() { return goods_id;}

    public void setGoods_id(String goods_id) { this.goods_id = goods_id;}

    public int getGoods_num() { return goods_num;}

    public void setGoods_num(int goods_num) { this.goods_num = goods_num;}

    public String getUser_id() { return user_id;}

    public void setUser_id(String user_id) { this.user_id = user_id;}

    public int getType() { return type;}

    public void setType(int type) { this.type = type;}

    public boolean isIs_install() { return is_install;}

    public void setIs_install(boolean is_install) { this.is_install = is_install;}

    public String getProvince() { return province;}

    public void setProvince(String province) { this.province = province;}

    public String getCity() { return city;}

    public void setCity(String city) { this.city = city;}

    public String getCounty() { return county;}

    public void setCounty(String county) { this.county = county;}

    public String getAddress() { return address;}

    public void setAddress(String address) { this.address = address;}

    public String getConsignee() { return consignee;}

    public void setConsignee(String consignee) { this.consignee = consignee;}

    public String getPhone() { return phone;}

    public void setPhone(String phone) { this.phone = phone;}

    public float getGoods_price() { return goods_price;}

    public void setGoods_price(float goods_price) { this.goods_price = goods_price;}

    public float getInstall_fee() { return install_fee;}

    public void setInstall_fee(float install_fee) { this.install_fee = install_fee;}

    public float getAdded_fee() { return added_fee;}

    public void setAdded_fee(float added_fee) { this.added_fee = added_fee;}

    public float getDiscount_amount() { return discount_amount;}

    public void setDiscount_amount(float discount_amount) { this.discount_amount = discount_amount;}

    public float getOrder_amount() { return order_amount;}

    public void setOrder_amount(float order_amount) { this.order_amount = order_amount;}

    public int getPay_type() { return pay_type;}

    public void setPay_type(int pay_type) { this.pay_type = pay_type;}

    public String getExpress_code() { return express_code;}

    public void setExpress_code(String express_code) { this.express_code = express_code;}

    public String getExpress_name() { return express_name;}

    public void setExpress_name(String express_name) { this.express_name = express_name;}

    public String getExpress_no() { return express_no;}

    public void setExpress_no(String express_no) { this.express_no = express_no;}

    public int getStatus() { return status;}

    public void setWuliu_type(int wuliu_type) {
        this.wuliu_type = wuliu_type;
    }

    public int getWuliu_type() {
        return wuliu_type;
    }

    public String getProvince_name() {
        return province_name;
    }

    public String getCity_name() {
        return city_name;
    }

    public String getCounty_name() {
        return county_name;
    }

    public void setProvince_name(String province_name) {
        this.province_name = province_name;
    }

    public void setCity_name(String city_name) {
        this.city_name = city_name;
    }

    public void setCounty_name(String county_name) {
        this.county_name = county_name;
    }

    public boolean showDeliveryStatus() {
        return (status == ORDER_STATUS_WAIT_FOR_DELIVERY || status == ORDER_STATUS_FINISHED) && wuliu_type == 0;
    }

    /**
     * 增值费订单
     *
     * @return
     */
    public boolean isAddedType() {
        return added_fee > 0f;
    }

    public boolean showBottomStatus() {
        if (isAddedType()) {
            return status == ORDER_STATUS_WAIT_TO_PAY || status == ORDER_STATUS_PAIED || status == ORDER_STATUS_WAIT_FOR_DELIVERY || status == ORDER_STATUS_FINISHED || status == ORDER_STATUS_WAIT_TO_REFUND;
        }
        return (status == ORDER_STATUS_WAIT_TO_PAY || status == ORDER_STATUS_WAIT_FOR_DELIVERY);
    }

    /**
     * 显示我已同意并阅读...
     *
     * @return
     */
    public boolean showAddedFeeAgreeTips() {
        return isAddedType() && status == ORDER_STATUS_WAIT_TO_PAY;
    }

    /**
     * 付款区显示增值费协议
     *
     * @return
     */
    public boolean showAddedFeePolicyInPriceArea() {
        return isAddedType() && (status == ORDER_STATUS_PAIED || status == ORDER_STATUS_FINISHED || status == ORDER_STATUS_WAIT_TO_REFUND);
    }

    /**
     * 付款区显示退款提醒协议
     *
     * @return
     */
    public boolean showRefundPolicyTips() {
        return isAddedType() && (status == ORDER_STATUS_WAIT_FOR_DELIVERY);
    }

    /**
     * 是否显示操作按钮
     *
     * @return
     */
    public boolean showOperateButton() {
        if (isAddedType()) {
            return status == ORDER_STATUS_WAIT_TO_PAY || status == ORDER_STATUS_PAIED || status == ORDER_STATUS_WAIT_FOR_DELIVERY || status == ORDER_STATUS_FINISHED;
        }
        return (status == ORDER_STATUS_WAIT_TO_PAY || status == ORDER_STATUS_WAIT_FOR_DELIVERY);
    }

    public boolean showPriceLayout() {
        return status == ORDER_STATUS_WAIT_TO_PAY;
    }

    /**
     * 是否显示底部状态区域
     *
     * @return
     */
    public boolean showBottomLayout() {
        if (!isAddedType()) {
            return status == ORDER_STATUS_WAIT_TO_PAY || status == ORDER_STATUS_WAIT_FOR_DELIVERY;
        }
        return status == ORDER_STATUS_WAIT_TO_PAY || status == ORDER_STATUS_PAIED || status == ORDER_STATUS_WAIT_FOR_DELIVERY || status == ORDER_STATUS_FINISHED || status == ORDER_STATUS_WAIT_TO_REFUND;
    }

    public void setStatus(int status) { this.status = status;}

    public Object getRemark() { return remark;}

    public void setRemark(Object remark) { this.remark = remark;}

    public String getPay_time() { return pay_time;}

    public void setPay_time(String pay_time) { this.pay_time = pay_time;}

    public String getCreate_time() { return create_time;}

    public void setCreate_time(String create_time) { this.create_time = create_time;}

    public String getUpdate_time() { return update_time;}

    public void setUpdate_time(String update_time) { this.update_time = update_time;}

    public String getGoods_name() { return goods_name;}

    public void setGoods_name(String goods_name) { this.goods_name = goods_name;}

    public String getHead_img() { return head_img;}

    public void setHead_img(String head_img) { this.head_img = head_img;}

    public ExpressInfoBean getExpress_info() { return express_info;}

    public void setExpress_info(ExpressInfoBean express_info) { this.express_info = express_info;}

    public String getFullAddress() {
        return new StringBuilder().append(province_name)
                .append(city_name)
                .append(county_name)
                .append(address)
                .toString()
                .replace("null", "");
    }

    public String getStatusStr() {
        String statusStr = "";
        switch (status) {
            case ORDER_STATUS_WAIT_TO_PAY:
                statusStr = "等待买家付款";
                break;
            case ORDER_STATUS_PAIED:
                statusStr = "等待平台发货";
                break;
            case ORDER_STATUS_WAIT_FOR_DELIVERY:
                statusStr = "平台已发货";
                break;
            case ORDER_STATUS_FINISHED:
                statusStr = "已完成";
                break;
            case ORDER_STATUS_WAIT_TO_REFUND:
                statusStr = "退款审核中";
                break;
            case ORDER_STATUS_REFUNDED:
                statusStr = "退款成功";
                break;
            case ORDER_STATUS_CANCELED:
                statusStr = "已取消";
                break;
        }
        return statusStr;
    }


    /**
     * 是否处于可申请退款
     *
     * @return
     */
    public boolean isRefundable() {
        return isAddedType() && (status == ORDER_STATUS_PAIED || status == ORDER_STATUS_FINISHED);
    }

    public String getOperateButtonCaptionStr() {
        String statusStr = "";
        switch (status) {
            case ORDER_STATUS_WAIT_TO_PAY:
                statusStr = "立即支付";
                break;
            case ORDER_STATUS_PAIED:
                statusStr = isAddedType() ? "退款" : "";
                break;
            case ORDER_STATUS_WAIT_FOR_DELIVERY:
                statusStr = "确认收货";
                break;
            case ORDER_STATUS_FINISHED:
                statusStr = isAddedType() ? "退款" : "";
                break;
            case ORDER_STATUS_WAIT_TO_REFUND:
                statusStr = "";
                break;
            case ORDER_STATUS_REFUNDED:
                statusStr = "";
                break;
            case ORDER_STATUS_CANCELED:
                statusStr = "";
                break;
        }
        return statusStr;
    }

    /**
     * 是否已经付款
     *
     * @return
     */
    public boolean isPaied() {
        return status > ORDER_STATUS_WAIT_TO_PAY && status != ORDER_STATUS_CANCELED;
    }

    /**
     * 是否等待付款
     *
     * @return
     */
    public boolean isWaitToPay() {
        return status == ORDER_STATUS_WAIT_TO_PAY;
    }

    /**
     * wait for delivery
     *
     * @return
     */
    public boolean isWaitForDelivery() {
        return status == ORDER_STATUS_WAIT_FOR_DELIVERY;
    }

    public boolean needShowRefundStatus() {
        return status == ORDER_STATUS_WAIT_TO_REFUND || status == ORDER_STATUS_REFUNDED;
    }

    public String getRefundStatusStr() {
        String refunsStatusStr = "";
        switch (status) {
            case ORDER_STATUS_WAIT_TO_REFUND:
                refunsStatusStr = "平台将会及时和您联系退款事宜";
                break;
            case ORDER_STATUS_REFUNDED:
                refunsStatusStr = "押金已退回原支付账户";
                break;
        }
        return refunsStatusStr;
    }

    public static class ExpressInfoBean {
        /**
         * LogisticCode : 812431841403
         * ShipperCode : YTO
         * Traces : [{"AcceptStation":"【浙江省杭州市滨江区滨和公司】 已收入","AcceptTime":"2017-12-02 08:40:47"},{"AcceptStation":"客户 签收人: 丰巢柜 已签收 感谢使用圆通速递，期待再次为您服务","AcceptTime":"2017-12-02 11:26:11"}]
         * Reason : 物流数据
         */

        private String LogisticCode;
        private String ShipperCode;
        private String Reason;
        private List<TracesBean> Traces;

        public String getLogisticCode() { return LogisticCode;}

        public void setLogisticCode(String LogisticCode) { this.LogisticCode = LogisticCode;}

        public String getShipperCode() { return ShipperCode;}

        public void setShipperCode(String ShipperCode) { this.ShipperCode = ShipperCode;}

        public String getReason() { return Reason;}

        public void setReason(String Reason) { this.Reason = Reason;}

        public List<TracesBean> getTraces() { return Traces;}

        public void setTraces(List<TracesBean> Traces) { this.Traces = Traces;}

        public static class TracesBean {
            /**
             * AcceptStation : 【浙江省杭州市滨江区滨和公司】 已收入
             * AcceptTime : 2017-12-02 08:40:47
             */

            private String AcceptStation;
            private String AcceptTime;

            public String getAcceptStation() { return AcceptStation;}

            public void setAcceptStation(String AcceptStation) { this.AcceptStation = AcceptStation;}

            public String getAcceptTime() { return AcceptTime;}

            public void setAcceptTime(String AcceptTime) { this.AcceptTime = AcceptTime;}
        }
    }
}
